import { Controller, UseGuards } from '@nestjs/common';
import { ApiUseTags, ApiBearerAuth } from '@nestjs/swagger';
import { InjectModel } from 'nestjs-typegoose';
import { ModelType } from '@typegoose/typegoose/lib/types';

import { Crud } from 'nestjs-mongoose-crud'
import { Role } from '@lib/db/models/role.model';
import { AuthGuard } from '@nestjs/passport';

class CreateRoleDto extends Role {
}

@Crud({
  model: Role,
  routes: {
    find: {
      populate: ['permission']
    },
    create: {
      dto: CreateRoleDto
    }
  }
})
@Controller('roles')
@ApiUseTags('角色')
@UseGuards(AuthGuard('jwt'))
@ApiBearerAuth()
export class RolesController {
  constructor(
    @InjectModel(Role) private readonly model: ModelType<Role>
  ) { }
}
